package com.groupjx;

import com.groupjx.api.JXApi;
import com.groupjx.vo.*;

import java.util.Arrays;
import java.util.List;

/**
 * 示例
 */
public class Example {


    /**
     * 登录
     */
    public void testLogin() {
        ResultVO resultVO = new JXApi().login("自己的账号", "自己的密码");
        System.out.println(resultVO);
    }


    /**
     * 获取用户信息
     */
    public void testGetUserInfo() {
        ResultVO resultVO = new JXApi().getUserInfo("自己的token");
        System.out.println(resultVO);
    }


    /**
     * 获取商品信息
     */
    public void testGetGoodsInfoPage() {
        ResultVO resultVO = new JXApi().getGoodsInfoPage("自己的token",
                GoodsInfopPageReqVO.builder().shopName("激想正品店").pageNo(1).pageSize(50).build());
        System.out.println(resultVO);
    }


    /**
     * 获取订单结算信息
     */
    public void testSettlement() {
        List<OrderSettlementReqVO.Item> items = Arrays.asList(
                OrderSettlementReqVO.Item.builder().inventoryId("1888163956208435209").count(2).build(),
                OrderSettlementReqVO.Item.builder().inventoryId("1888210498545598466").count(2).build());

        OrderSettlementReqVO buildParams = OrderSettlementReqVO.builder().items(items).build();

        ResultVO resultVO = new JXApi().settlement("自己的token", buildParams);

        System.out.println(resultVO);
    }


    /**
     * 创建订单
     */
    public void testCreateOrder() {

        OrderCreateReqVO.ShopItem shopItem1 = OrderCreateReqVO.ShopItem.builder()
                .shopId("1888148823730028546") //店铺id
                .userRemark("1店备注") //店铺备注
                .items(Arrays.asList(OrderCreateReqVO.Item.builder().inventoryId("1888163956208435209").count(3).build())) //商品列表
                .totalPrice(50700) //店铺小计总金额，吊牌价
                .discountPrice(14160) //店铺小计折扣价
                .deliveryPrice(1140)    //店铺小计运费
                .payPrice(14160 + 1140) //店铺小计实付金额
                .skuCount(3)    //店铺小计sku数量
                .build();


        OrderCreateReqVO.ShopItem shopItem2 = OrderCreateReqVO.ShopItem.builder()
                .shopId("1888148888947261442")
                .userRemark("2店备注")
                .items(Arrays.asList(OrderCreateReqVO.Item.builder().inventoryId("1888210498545598466").count(2).build()))
                .totalPrice(33800)
                .discountPrice(8496)
                .deliveryPrice(760)
                .payPrice(8496 + 760)
                .skuCount(2)
                .build();

        OrderCreateReqVO buildParams = OrderCreateReqVO.builder()
                .extendOrderId("外部单号37812372193")
                .tempAddress(OrderCreateReqVO.TempAddress.builder().receiverName("张三").receiverMobile("15900688888").receiverDetailAddress("上海上海市浦东新区锦绣东路2777弄21号").build())
                .price(OrderCreateReqVO.Price.builder()
                        .totalPrice(84500) //订单总金额，吊牌价
                        .discountPrice(22656) //订单总折扣价
                        .deliveryPrice(1900) //订单总运费
                        .payPrice(22656 + 1900) //订单总实付金额
                        .skuCount(5) //订单总sku数量
                        .build())
                .shopItems(Arrays.asList(shopItem1, shopItem2))
                .build();


        ResultVO resultVO = new JXApi().createOrder("自己的token", buildParams);

        System.out.println(resultVO);
    }


    /**
     * 订单分页
     */
    public void testQueryOrderPage() {
        ResultVO resultVO = new JXApi().orderPage("自己的token", OrderPageReqVO.builder().pageNo(1).pageSize(50).build());
        System.out.println(resultVO);
    }


    /**
     * 取消订单
     */
    public void testCancelOrder() {
        ResultVO resultVO = new JXApi().cancelOrder("自己的token", OrderCancelReqVO.builder().orderNo("T2025030613131640").build());
        System.out.println(resultVO);
    }


}

